local skynet = require "skynet"
local filelog = require "filelog"
local msghelper = require "ranklistsvrhelper"
local ranklistredismng = require"ranklistredismng"
local logicmng = require "logicmng"
local timer = require "timer"
local PlayerdataDAO = require "playerdatadao"
local configdao  = require "configdao"
local timetool = require "timetool"
local redisdao = require "dao.redisdao"
require "enum"

local filename = "ranklisttimer.lua"

local RankListTimer = {}

function RankListTimer.process(session, source, event, ...)
	local f = RankListTimer[event] 
	if f == nil then
		filelog.sys_error(filename.." RankListTimer.process invalid event:"..event)
		return nil
	end
	f(...)	 
end

--定时刷新排行榜
function RankListTimer.timeing_uprank(timerid, request)
	local server = msghelper:get_server()
	local remainNum = ranklistredismng.getmax_cut_size(request.rank_key)

	ranklistredismng.update_realrank_tostablerank(request.rank_key,0,remainNum)

	-- 下一次执行直接一天以后
	local upsptime = request.upsptime
    timer.settimer(upsptime * 100, "timeing_uprank",request)
end

function RankListTimer.timeing_refrank(timerid, request)
	ranklistredismng.delete_rank_data(request.rank_key, 0)
	-- 下一次执行直接一天以后
	local upsptime = request.upsptime
    timer.settimer(upsptime * 100, "timeing_refrank",request)
end
return RankListTimer